package lianxi5;

import org.w3c.dom.ls.LSOutput;

public class MathText {
    public static void main(String[] args) {
        // abs获取绝对值
        System.out.println(Math.abs(-254.34));

        //ceil向上取整
        double ceil = Math.ceil(4.2);
        System.out.println("向上取整：" + ceil);

        //floor向下取整
        double floor = Math.floor(4.8);
        System.out.println("向下取整：" + floor);

        //round四舍五入
        long a = Math.round(3.4);
        long b = Math.round(3.5);
        System.out.println("3.4四舍五入：" + a);
        System.out.println("3.5四舍五入：" + b);

        //max获取最大值
        int max = Math.max(200,300);
        System.out.println("最大值：" + max);

        //pow返回a的b次幂
        double c = Math.pow(3, 4);
        System.out.println("3的4次幂：" + c);

        //random返回0-1之间的随机数
        double r = Math.random();
        System.out.println("随机数：" + Math.round(r*100));


    }


}
